!===============================================================
!
! Funzione di Shekel 7 minimi (n=4) 
!
!===============================================================
!			VARIABLE BOUNDS
!===============================================================
!        0.D+0               1.D+1         Limits of variable 1
!        0.D+0               1.D+1            "        "      2
!        0.D+0               1.D+1            "        "      3
!        0.D+0               1.D+1            "        "      4

SUBROUTINE SHEKEL7(X,N,F)

      IMPLICIT NONE

      INTEGER          :: N
      DOUBLE PRECISION :: X(N), F

      DOUBLE PRECISION :: A(7,4), C(7), FA
      INTEGER          :: I, J

      DO I=1,4
         A(1,I)=4.D0
         A(2,I)=1.D0
         A(3,I)=8.D0
         A(4,I)=6.D0
      END DO
      DO I=1,2
         A(5,2*(I-1)+1)=3.D0
         A(5,2*I)=7.D0
         A(6,2*(I-1)+1)=2.D0
         A(6,2*I)=9.D0
         A(7,I)=5.D0
         A(7,I+2)=3.D0
      END DO

      C(1)=0.1D0
      C(2)=0.2D0
      C(3)=0.2D0
      C(4)=0.4D0
      C(5)=0.4D0
      C(6)=0.6D0
      C(7)=0.3D0

      F  = 0.0D0
      FA = 0.0D0

      DO I=1,7
         DO J=1,4
            FA = FA +(X(J)-A(I,J))**2
         END DO
         IF ((FA+C(I)).EQ.0.D0) THEN
            F=1.D25
            RETURN
         ENDIF
         F = F -1.0D0/(FA+C(I)) 
         FA = 0.0D0
      END DO

	  !F = F + 10.4028188369303d0

      RETURN

END
